import React,{Component} from 'react';
import bootcss from 'bootstrap/dist/css/bootstrap.css';

export default class BindEvent extends Component{
    constructor(){
        super();
        this.state={
            msg:'哈哈'
        }
    }

    render(){
        return <div className='container'>
        <div className="row">
        <div className="col-md-3">
        <button className="btn btn-primary" onClick={()=>this.changeMsg()}>Click me</button>
        <input type='text' className='form-control' value={this.state.msg} onChange={()=>this.changeVal()} ref='txtMsg'/>
        </div>
        </div>
        </div>
    }

    changeMsg=()=>{
        this.setState({
            msg:'hello'
        });
    }
    changeVal=()=>{
       this.setState({
           'msg':this.refs.txtMsg.value
       });
       console.log(this.state.msg);
    }
}